<?php

class SF_PromoteEvents_Block_Adminhtml_Eventslist_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('eventsGrid');
        $this->setDefaultSort('id');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);

    }
    protected function _prepareCollection()
    {
        $collection = Mage::getModel('promoteevents/events')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
    protected function _prepareColumns()
    {
        $this->addColumn('id', array(
            'header'	=> $this->__('ID'),
            'align'		=> 'left',
            'index'		=> 'id',
        ));
        $this->addColumn('event_code', array(
            'header'	=> $this->__('Event Code'),
            'align'	    => 'left',
            'index' 	=> 'event_code',
        ));
        $this->addColumn('event_title', array(
            'header'	=> $this->__('Event Title'),
            'align'	    => 'left',
            'index' 	=> 'event_title',
        ));

        $this->addColumn('from_date', array(
            'header'    => $this->__('From Date'),
            'align'     => 'right',
            'type'      => 'datetime',
            'renderer' => $this->getGeneral_FormatDate('m/d/Y H:i:s'),
            'index'     => 'from_date',
        ));
        
        $this->addColumn('to_date', array(
            'header'    => $this->__('To Date'),
            'align'     => 'right',
            'type'      => 'datetime',
            'renderer' => $this->getGeneral_FormatDate('m/d/Y H:i:s'),
            'index'     => 'to_date',
        ));
        
        $this->addColumn('is_active', array(
            'header'	=> $this->__('Status'),
            'align'		=> 'left',
            'index'		=> 'is_active',
            'renderer'=> 'promoteevents/widget_grid_column_renderer_status',
        ));

        $this->addColumn('action', array(
                'header'    =>  $this->__('Action'),
                'type'      => 'action',
                'getter'    => 'getId',
                'actions'   => array(
                    array(
                        'caption'   => $this->__('Edit'),
                        'url'       => array('base'=> '*/*/edit'),
                        'field'     => 'id'
                    )
                ),
                'filter'    => false,
                'sortable'  => false,
                'index'     => 'stores',
                'is_system' => true,
        ));
        
        $this->addColumn('manage', array(
            'header'    =>  $this->__('Action'),
            'type'      => 'action',
            'getter'    => 'getId',
            'actions'   => array(
                array(
                    'caption'   => $this->__('Manege'),
                    'url'       => array('base'=> 'promoteevents/adminhtml_product/index'),
                    'field'     => 'id'
                )
            ),
            'filter'    => false,
            'sortable'  => false,
            'index'     => 'stores',
            'is_system' => true,
        ));
        return parent::_prepareColumns();
    }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('id');
        $this->getMassactionBlock()->setFormFieldName('promoteevents');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => $this->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => $this->__('Are you sure?')
        ));
        return $this;
    }

    public function getRowUrl($row)
    {
//         return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }

}
